<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>面向对象的多态</title>
</head>
<body>
    <script>
        function User(){}
        User.prototype.show = function(){
            console.log(this.description());
        }


        function Member(){}
        Member.prototype.__proto__ = User.prototype;
        Member.prototype.description = function(){
            return '我是member';
        }


        function Admin(){}
        Admin.prototype.__proto__ = User.prototype;
        Admin.prototype.description = function(){
            return '我是admin';
        }


        function Enterprise(){}
        Enterprise.prototype.__proto__ = User.prototype;
        Enterprise.prototype.description = function(){
            return '我是enterprise';
        }


        for (const obj of [new Member(),new Admin(),new Enterprise()]) {
            obj.show();
        }
    </script>
</body>
</html>